<?php
namespace plugins\log\controller;
use cmf\controller\PluginAdminBaseController;
use think\Db;
use plugins\log\model\SysLogsModel;


class AdminIndexController extends PluginAdminBaseController
{
	protected function _initialize()
	{
	}
	/**
	*	日志首页
	*/
	public function index()
	{
	    $param = $this->request->param();
	    
	    $search = [
	        'start_time' => isset( $param [ 'start_time' ] ) ? $param [ 'start_time' ] : '',
	        'end_time' => isset( $param [ 'end_time' ] ) ? $param [ 'end_time' ] : '',
	    ];
	    
	    $pagesize = isset( $param [ 'pagesize' ] ) ? $param [ 'pagesize' ] : 20;
	    $list = SysLogsModel::order( 'add_time desc' );
	    
	    if( !empty( $search [ 'start_time' ] ) ){
	        $list = $list->where( 'add_time' , '>=' , strtotime( $search[ 'start_time' ] ) );
	    }
	    
	    if( !empty( $search [ 'end_time' ] ) ){
	        $list = $list->where( 'add_time' , '<=' , strtotime( $search[ 'end_time' ] ) );
	    }
	    
	    $list = $list->paginates( $pagesize  );
	    
	    $this->assign( "search" , $search );
	    
	    //return api_json_echo( true , '成功' );
	    $this->assign( "list" , $list );
	    return $this->fetch();
	   //return $this->success( '成功' );
	}
	
	
	
}